<div class="main-content">
	<div class="breadcrumbs" id="breadcrumbs">
		<script type="text/javascript">
			try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
		</script>

		<!-- .breadcrumb -->
	</div>
	<!-- Main content -->
	<div class="page-content">
    	<div class="row">
    	    <div class="page-header">
    			<h1>列表</h1>
    		</div>
    		<div class=" col-md-12 col-sm-12 col-xs-12 form">
                <div class="row">
            
                <form action="<?php echo base_url().'admin/activity/baoyang_order'?>" method="get">
                    <div class="wh">
                    	<label>订单号：</label>
                        <input type="text" name="order_no" value="<?php if (isset($order_no))echo $order_no;?>" />
                    </div>
                   <div class="wh">
                	<label>订单状态：</label>
                    	<select name="status" id="status">
                    		<option value="-1" <?php if (empty($status)||(!empty($status)&&$status ==-1))echo "selected";?>>全部</option>
                    	
                    		<option value="1" <?php if (isset($status)&&$status ==6)echo "selected";?>>已支付</option>
                            <option value="7" <?php if (isset($status)&&$status ==7)echo "selected";?>>已退款</option>
                    		
                    	</select>
                    </div>
                    <div class="wh">
                	<label>时间：</label>
                    <input type="text" name="start_time" id="start_time" style="width:100px;" value="<?php if (isset($start_time)) echo $start_time;?>"/>到
                    <input type="text" name="end_time" id="end_time" style="width:100px;" value="<?php if (isset($end_time)) echo $end_time;?>"/>
                    </div>
                    <div class="wh">
                        <button class="btn btn-sm btn-info" type="submit"><i class="icon-search"></i>查询</button>
                    </div> 
                </form>
                </div>
            </div>
            <input type="hidden" name="upid" id="upid" value=""/>
            <div class="col-xs-12 margin_t margin_b">
				<div class="table-responsive  tab">
					<table id="sample-table-1" class="table table-striped table-bordered table-hover">
						<thead>
							<tr>
								
								<th>订单号</th>
                               
                                <th>手机号</th>
                                <th>套餐</th>
                                <th>价格</th>
                                <th>实付价格</th>
                                <th>支付状态</th>
                                <th>是否核销</th>
                                <th>下单时间</th>
                                <th>邀请人</th>
                                <th>操作</th>
                                
							</tr>
						</thead> 
						<tbody>
						<?php if (isset($result)&&count($result)>0){
                            	foreach ($result as $app){
                            	?>
							<tr>
								
								
                                <td><p><?php echo $app['order_no'];?></p></td>
                                
                                <td><p><?php echo $app['goods_name'];?></p></td>
                                <td><p><?php echo $app['user_mobile'];?></p></td>
                                <td><p><?php echo $app['goods_price'];?></p></td>
                                <td><p><?php echo $app['order_price'];?></p></td>
                              
                                <td><p>
								<?php
											if($app['status']==7){
												echo '已退款';
										
											}elseif($app['status'] == 1){
												echo "已支付";
											}
											?>
                                
                                </p></td>
                                <td><p><?php if($app['hexiao_status']==1){echo '已核销';}else{echo '未核销';}?></p></td>
                                <td><p><?php echo $app['create_time'];?></p></td>
                                <td><p><?php echo $app['from_user'];?></p></td>
                                <td><p>
									<a href="<?php echo base_url().'admin/activity/baoyang_jiesuan/'.$app['id']?>" class="btn btn-danger btn-sm">
                                    <?php if(empty($app['jiesuan'])):?>
                                    结算
                                    <?php else:?>
                                    已结算
                                    <?php endif;?>
                                    </a>
                                    
                                    <a href="javascript:void(0)" onclick="cancelmodal('<?php echo $app['order_id'];?>')" data-toggle="modal" class="btn btn-danger btn-sm"><i class="icon-trash"></i>取消</a>
								</p></td>
    						</tr>
    						<?php }
                            }else{?>
                            <tr>
                            	<td colspan="9">无数据</td>
                            </tr>
                            <?php }?>
                            </tbody>
                         </table>
                     </div><!-- /.table-responsive -->
				</div>
                
            </div><!-- /.row -->
		</div><!-- /.page-content -->
	</div><!-- /.main-content -->
	<div id="delModal" class="modal fade" role="dialog" aria-hidden="true">
		<div class="modal-dialog" style="width: 300px">
			<div class="modal-content">
				<div class="modal-header">
				  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				  <h3>提示信息</h3>
				</div>
				<div class="modal-body">
				  <p>确定删除该身份认证审核吗？</p>
				</div>
				<div class="modal-footer">
				  <a id="delbtn" href="#" class="btn btn-danger">确定</a>
				  <a href="#" class="btn btn-info" data-dismiss="modal" aria-hidden="true">取消</a>
				</div>
			</div>
		</div>
	</div>
    <div id="cancelModal" class="modal fade" role="dialog" aria-hidden="true">
	<div class="modal-dialog" style="width: 300px">
		<div class="modal-content">
			<div class="modal-header">
			  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
			  <h3>提示信息</h3>
			</div>
			<div class="modal-body">
			  <p>取消订单后将无法恢复，已支付的金额会直接退回用户支付账户<br>确定要取消所选订单吗？</p>
			</div>
			<div class="modal-footer">
			  <input type="hidden" id="cancel_order_id" value="">
			  <a id="cancelbtn" href="#" onclick="cancel()" class="btn btn-danger">确定</a>&nbsp;&nbsp;&nbsp;
			  <a href="#" class="btn btn-info" data-dismiss="modal" aria-hidden="true">取消</a>
			</div>
		</div>
	</div>
</div>
	<script type="text/javascript">
	function cancelmodal(id){
	$("#cancel_order_id").val(id);
    $('#cancelModal').modal('show');
}
	function delmodal(id){
		$("#delbtn").attr('href','<?php echo base_url().'admin/user/del_check/'?>'+id);
	    $('#delModal').modal('show');
	}
	function cancel(){
	$('#cancelModal').modal('hide');
	showLoading('取消中...');
	$.ajax( {
        url:'<?php echo site_url("admin/activity/cancel")?>',
        data:{order_id:$('#cancel_order_id').val()},
        type:'post',
        cache:false,
        dataType:'json',    
        success:function(result) {
        	hideLoading();
        	if(result.ret == '200'){
            	if(result.data.code == '0'){
            		window.location.reload();
            	}else{
            		alert("取消失败:"+result.data.msg);
            	}
        		
			}else {
				alert("取消失败:"+result.msg);
			}
        },
        error : function() {
        	hideLoading();
			alert("error");
        }
	});
}

layui.use(['form','element','laydate'], function(){
  var form = layui.form,
  	element = layui.element,
  	laydate = layui.laydate;

  //时间选择器
  laydate.render({
    elem: '#start_time'
    ,type: 'datetime'
  });
    //时间选择器
  laydate.render({
    elem: '#end_time'
    ,type: 'datetime'
  }); 


});
	</script>